package com.appleyk.component;

import javax.servlet.*;
import java.io.IOException;

/**
 * <p>越努力，越幸运</p>
 * 自定义web filter组件
 * @author appleyk
 * @version V.0.1.1
 * @blob https://blog.csdn.net/appleyk
 * @date created on  10:31 下午 2021/2/27
 */
public class MyFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("MyFilter init() method is called.");
    }

    @Override
    public void destroy() {
        System.out.println("MyFilter destroy() method is called.");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("MyFilter doFilter() method is called.");
        System.out.println("====== 对request和response放行");
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
